var that = this;
class Tab {
    constructor(id) {
        that = this;
        //获取元素
        this.main = document.querySelector(id);
        this.lis = this.main.querySelectorAll('.tabnav li');
        this.sections = this.main.querySelectorAll('.content section');
        // this.btnadd = this.main.querySelector('.addcomment');
        // this.confirst = this.main.querySelector('.confirst');


        //调用方式2
        this.init();
    }
    init() {
        //初始化操作 让相关元素绑定事件
        for (var i = 0; i < this.lis.length; i++) {
            this.lis[i].index = i;
            this.lis[i].onmouseover = this.toggleTab;
        }
    }
    //1.切换功能
    toggleTab() {
        that.clearClass();
        this.className = 'current';
        that.sections[this.index].className = 'pitch-on';
    }
    clearClass() {
        for (var i = 0; i < this.lis.length; i++) {
            this.lis[i].className = '';
            this.sections[i].className = '';
        }
    }
}
//调用方式1
// var tab = new Tab('.head');
// tab.init();
new Tab('.tab');

var callback = document.querySelector('.callback');
callback.onclick = function () {
    window.location.href = 'index2.html';
}

window.onload = function () {
    var callback = document.querySelector('.callback');
    callback.onclick = function () {
        window.location.href = '../index/index3.html';
    }
}